export interface IImageProp {
  _id?: string
  url?: string
  fitUrl?: string
}
// ColumnList.vue
export interface IColumnProp {
  _id: string
  avatar?: IImageProp
  title: string
  description: string
}
export type TColumnList = IColumnProp[]

// PostsList.vue
export interface IPostsProp {
  _id?: string
  title: string
  excerpt?: string
  content?: string
  image?: IImageProp | string
  createdAt?: string
  column: string
  author?: string | IUserProp
}
export type TPostsList = IPostsProp[]

// GlobalHeader.vue
export interface IUserProp {
  isLogin: boolean
  nickName?: string
  _id?: string
  column?: string
  email?: string
  description?: string
  avatar?: IImageProp
}

// ValidateInput.vue
export enum ERuleType {
  'REQUIRED' = 'required',
  'EMAIL' = 'email',
  'RANGE' = 'range',
  'VALIDATOR' = 'validator'
}
export interface IRuleProp {
  type: ERuleType | string
  message: string
  min?: number
  max?: number
  trigger?: string
  validator?: () => boolean
}
export type TRulesProp = IRuleProp[]
export interface IRules {
  [key: string]: TRulesProp
}

// ValidateForm.vue
export type TValidateFun = (trigger?: string) => boolean
export type TCleanFun = () => void

// bus.ts
export type TMittEvents = {
  'form-validate': TValidateFun
  'form-clean': TCleanFun
  'dropdown-item-click': boolean
}

// 全局提示
interface IMessage {
  status: boolean
  message?: string
}

// 全局提示类型
export enum EMessageType {
  'INFO' = 'info',
  'SUCCESS' = 'success',
  'DANGER' = 'danger',
  'WARNING' = 'warning'
}

// 全局提示参数
export interface IMessageParams {
  type: EMessageType | string
  message: string
  timeout?: number
}

// Modal
export interface IModalParams {
  title?: string
  content?: string
}

// store
export interface IStore {
  token: string
  loading: boolean
  user: IUserProp
  columnList: TColumnList
  postsList: TPostsList
  error: IMessage
}

// Uploader.vue
export type TUploadStatus = 'ready' | 'loading' | 'success' | 'error'
export type TUploadBefore = (file: File) => boolean
export enum EUploadConditionType {
  'SIZE' = 'size',
  'FORMAT' = 'format',
  'EMPTY' = ''
}
export interface IUploadCondition {
  size?: number
  format?: string[]
}

// 接口返回数据格式
export interface IResponseData<D> {
  code: number
  msg: string
  data: D
}
